import re

def appeared_for_(s, n):
    subs = {s[i:i+n] for i in range(len(s)-n+1)}  # get子串组成的列表
    return {item : len(re.findall(item, s)) for item in subs}   # 这个思路是真可以

s = '111kkka'

print(appeared_for_(s,2))